package com.wenbai.servicelightluxurystickers.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wenbai.servicelightluxurystickers.entity.StickForumMember;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StickForumMemberMapper extends BaseMapper<StickForumMember> {
    List<StickForumMember> selectByMemberId(String forumId);

    // 当前其他设为普通用户
    @Update("update stick_forum_member set role = '1' where forum_id = #{forumId} and role = '0' and user_id != #{userId}")
    void updateRoleOne(int forumId, int userId);

    // 当前设为管理员
    @Update("update stick_forum_member set role = '0' where forum_id = #{forumId} and user_id = #{userId}")
    void updateRoleZero(int forumId, int userId);

    @Update("update stick_forum set user_id = #{userId}")
    void updateUserManage(int userId);

    @Delete("delete from stick_forum_member where forum_id = #{forumId}")
    void deleteByForumId(int forumId);

    List<StickForumMember> selectForumMemberByUserId(int userId);
}
